﻿<Window x:Class="Cube.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:viewModels="clr-namespace:Cube.ViewModels"
        Title="MainWindow"        
        Width="800"
        Height="600"
        Background="Black"
        Loaded="Window_Loaded"
        Closed="Window_Closed">
    <Window.DataContext>
        <viewModels:MainWindowViewModel />
    </Window.DataContext>
    <Grid>
        <Viewport3D>
            <ModelVisual3D>                
                <ModelVisual3D.Content>
                    <Model3DGroup>
                        <GeometryModel3D>
                            <GeometryModel3D.Geometry>
                                <MeshGeometry3D TextureCoordinates="
                                                -1,1,  1,1,  1,-1, -1,-1,
                                                -1,1,  1,1,  1,-1, -1,-1,
                                                -1,1,  1,1,  1,-1, -1,-1,
                                                -1,1,  1,1,  1,-1, -1,-1,
                                                -1,1,  1,1,  1,-1, -1,-1,
                                                -1,1,  1,1,  1,-1, -1,-1"
                                                Positions="
                                                -1,-1,1, 1,-1,1, 1,1,1, -1,1,1,
                                                1,-1,1, 1,-1,-1 1,1,-1, 1,1,1,
                                                1,-1,-1, -1,-1,-1, -1,1,-1, 1,1,-1,
                                                -1,-1,-1, -1,-1,1, -1,1,1, -1,1,-1,
                                                -1,1,1, 1,1,1, 1,1,-1, -1,1,-1,
                                                -1,-1,-1, 1,-1,-1, 1,-1,1, -1,-1,1"
                                                TriangleIndices="             
                                                0,1,2
                                                0,2,3,
                                                4,5,6,
                                                4,6,7,
                                                8,9,10,
                                                8,10,11,
                                                12,13,14,
                                                12,14,15,
                                                16,17,18,
                                                16,18,19,
                                                20,21,22, 
                                                20,22,23"
                                                Normals="
                                                0,0,1,
                                                0,0,1,
                                                0,0,1,
                                                0,0,1,
                                                1,0,0,
                                                1,0,0,
                                                1,0,0,
                                                1,0,0,
                                                0,0,-1,
                                                0,0,-1,
                                                0,0,-1,
                                                0,0,-1,
                                                -1,0,0,
                                                -1,0,0,
                                                -1,0,0,
                                                -1,0,0,
                                                0,1,0,
                                                0,1,0,
                                                0,1,0,
                                                0,1,0,
                                                0,-1,0,
                                                0,-1,0,
                                                0,-1,0,
                                                0,-1,0"
                                                />
                            </GeometryModel3D.Geometry>

                            <GeometryModel3D.Material>
                                <MaterialGroup>
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <ImageBrush ImageSource="Assets/Cat.png"
                                                        Opacity="1"></ImageBrush>
                                        </DiffuseMaterial.Brush>

                                    </DiffuseMaterial>
                                </MaterialGroup>
                            </GeometryModel3D.Material>
                            
                            <GeometryModel3D.Transform>
                                <Transform3DGroup>
                                    <RotateTransform3D>
                                        <RotateTransform3D.Rotation>
                                            <AxisAngleRotation3D Axis="1 0 0"
                                                                 Angle="{Binding XAxisRotation}" />
                                        </RotateTransform3D.Rotation>
                                    </RotateTransform3D>
                                    <RotateTransform3D>
                                        <RotateTransform3D.Rotation>
                                            <AxisAngleRotation3D Axis="0 1 0"
                                                                 Angle="{Binding YAxisRotation}" />
                                        </RotateTransform3D.Rotation>
                                    </RotateTransform3D>
                                    <TranslateTransform3D OffsetX="{Binding XTranslation}"
                                                          OffsetY="{Binding YTranslation}"
                                                          OffsetZ="{Binding ZTranslation}" />
                                </Transform3DGroup>
                            </GeometryModel3D.Transform>
                        </GeometryModel3D>

                        <PointLight Color="White"
                                    Position="-5,3,3" />
                        <PointLight Color="White"
                                    Position="5,0,3" />
                        <AmbientLight Color="#FF222222" />
                    </Model3DGroup>                    
                </ModelVisual3D.Content>
            </ModelVisual3D>
            
            <Viewport3D.Camera>
                <PerspectiveCamera Position="{Binding CameraPosition}"
                                   LookDirection="0, 0, -1"
                                   UpDirection="0, 1, 0"
                                   FieldOfView="60">                    
                </PerspectiveCamera>
            </Viewport3D.Camera>
        </Viewport3D>
    </Grid>
</Window>
